// 游戏常量定义

// 棋子类型
export const PIECE_TYPES = {
    ROOK: 'rook',      // 车
    HORSE: 'horse',    // 马
    ELEPHANT: 'elephant', // 象/相
    ADVISOR: 'advisor',   // 士/仕
    GENERAL: 'general',   // 将/帅
    CANNON: 'cannon',    // 炮
    PAWN: 'pawn'         // 卒/兵
};

// 玩家颜色
export const COLORS = {
    RED: 'red',
    BLACK: 'black'
};

// 游戏状态
export const GAME_STATUS = {
    READY: 'ready',
    PLAYING: 'playing',
    PAUSED: 'paused',
    OVER: 'over',
    DRAW: 'draw'
};

// AI难度
export const AI_DIFFICULTY = {
    EASY: 'easy',
    MEDIUM: 'medium',
    HARD: 'hard'
};

// 棋盘配置
export const BOARD_CONFIG = {
    ROWS: 10,
    COLS: 9,
    CELL_SIZE: 70,      // 单元格大小（像素）
    MARGIN: 20,         // 边距
    BOARD_WIDTH: 9 * 70,   // 棋盘宽度
    BOARD_HEIGHT: 10 * 70, // 棋盘高度
    RIVER_TOP: 4,       // 河界顶部行
    RIVER_BOTTOM: 5,    // 河界底部行
    PALACE_LEFT: 3,     // 九宫格左侧列
    PALACE_RIGHT: 5,    // 九宫格右侧列
    RED_PALACE_TOP: 0,  // 红方九宫格顶部
    RED_PALACE_BOTTOM: 2, // 红方九宫格底部
    BLACK_PALACE_TOP: 7, // 黑方九宫格顶部
    BLACK_PALACE_BOTTOM: 9 // 黑方九宫格底部
};

// 棋子初始位置
export const INITIAL_POSITIONS = {
    [COLORS.RED]: [
        { type: PIECE_TYPES.ROOK, row: 9, col: 0 },
        { type: PIECE_TYPES.HORSE, row: 9, col: 1 },
        { type: PIECE_TYPES.ELEPHANT, row: 9, col: 2 },
        { type: PIECE_TYPES.ADVISOR, row: 9, col: 3 },
        { type: PIECE_TYPES.GENERAL, row: 9, col: 4 },
        { type: PIECE_TYPES.ADVISOR, row: 9, col: 5 },
        { type: PIECE_TYPES.ELEPHANT, row: 9, col: 6 },
        { type: PIECE_TYPES.HORSE, row: 9, col: 7 },
        { type: PIECE_TYPES.ROOK, row: 9, col: 8 },
        { type: PIECE_TYPES.CANNON, row: 7, col: 1 },
        { type: PIECE_TYPES.CANNON, row: 7, col: 7 },
        { type: PIECE_TYPES.PAWN, row: 6, col: 0 },
        { type: PIECE_TYPES.PAWN, row: 6, col: 2 },
        { type: PIECE_TYPES.PAWN, row: 6, col: 4 },
        { type: PIECE_TYPES.PAWN, row: 6, col: 6 },
        { type: PIECE_TYPES.PAWN, row: 6, col: 8 }
    ],
    [COLORS.BLACK]: [
        { type: PIECE_TYPES.ROOK, row: 0, col: 0 },
        { type: PIECE_TYPES.HORSE, row: 0, col: 1 },
        { type: PIECE_TYPES.ELEPHANT, row: 0, col: 2 },
        { type: PIECE_TYPES.ADVISOR, row: 0, col: 3 },
        { type: PIECE_TYPES.GENERAL, row: 0, col: 4 },
        { type: PIECE_TYPES.ADVISOR, row: 0, col: 5 },
        { type: PIECE_TYPES.ELEPHANT, row: 0, col: 6 },
        { type: PIECE_TYPES.HORSE, row: 0, col: 7 },
        { type: PIECE_TYPES.ROOK, row: 0, col: 8 },
        { type: PIECE_TYPES.CANNON, row: 2, col: 1 },
        { type: PIECE_TYPES.CANNON, row: 2, col: 7 },
        { type: PIECE_TYPES.PAWN, row: 3, col: 0 },
        { type: PIECE_TYPES.PAWN, row: 3, col: 2 },
        { type: PIECE_TYPES.PAWN, row: 3, col: 4 },
        { type: PIECE_TYPES.PAWN, row: 3, col: 6 },
        { type: PIECE_TYPES.PAWN, row: 3, col: 8 }
    ]
};

// 棋子价值（用于AI评估）
export const PIECE_VALUES = {
    [PIECE_TYPES.ROOK]: 900,
    [PIECE_TYPES.CANNON]: 450,
    [PIECE_TYPES.HORSE]: 400,
    [PIECE_TYPES.ELEPHANT]: 200,
    [PIECE_TYPES.ADVISOR]: 200,
    [PIECE_TYPES.GENERAL]: 10000,
    [PIECE_TYPES.PAWN]: 100
};

// 悔棋限制
export const UNDO_LIMIT = 10;

// 存储键名
export const STORAGE_KEYS = {
    GAME_PROGRESS: 'xiangqi_game_progress',
    SCORES: 'xiangqi_scores'
};